package com.company.demo.control;

import com.company.demo.bean.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;


@Controller//依赖注入
public class ThymeleafController {

    @RequestMapping("/test/myindex")
   public  String  indexHandle(Model model){

        Student student = new Student("战三 ",23);
        model.addAttribute("student",student);

        Student student1 = new Student("战三 ",23);
        Student student2 = new Student("网 ",25);
        Student student3 = new Student("你好好吃 ",58);
        Student student4 = new Student("但此时的 ",41);
        List<Student> students = new ArrayList<>();
        students.add(student1);
        students.add(student2);
        students.add(student3);
        students.add(student4);
        model.addAttribute("students",students);

        return  "index1";//返回模板页面
   }
}
